package org.myorg;

import java.io.*;

public class SFGA {
	public static void main(String[] args) throws Exception {

		/*		int geneLength = 1;
				int peopleNum = 20;
				double p_cross = 0.5;
				double p_mut = 0.5;
				int i_num = 10;

				double[] low = new double[1];
				double[] high = new double[1];

				low[0] = 0;
				high[0] = 2*3.1415926;



				FGA.ga(geneLength, low, high, peopleNum, p_cross, p_mut, i_num, new FFunction());*/

		String path = "/home/stanley/Documents/workspace/hadoop/hadoop-0.20.2/res/sres";
		File res = new File(path);

		if (res.exists()) {
			res.delete();
		}

		int geneLength = 1000;
		int peopleNum = 20;
		double p_cross = 0.5;
		double p_mut = 0.5;
		int i_num = 30000;
		long time = 120000000;
		int ln=2;

		double[] low = new double[1000];
		double[] high = new double[1000];

		for (int i = 0; i < 1000; i++) {
			low[i] = -100;
			high[i] = 100;
		}

		for (int i = 0; i < ln; i++) {
			long st = System.currentTimeMillis();
			FGA.ga(geneLength, low, high, peopleNum, p_cross, p_mut, i_num, new FF1(),time);
			long rt = System.currentTimeMillis() - st;
			System.out.println("run time is " + rt);

			FGene gene = FGA.best_people.getPersons()[FGA.best_people.getBest(new FF1())];
			RWF.wf(String.valueOf(gene.fitness),path);
		}
		
		System.out.println("Game over");

	}
	
}
